using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace MVCFramework
{
    /// <include file='Id.doc.xml' path='/doc/member[@name="T:Id`1"]/*'/>
    [Serializable]
    public struct Id<T> : IEquatable<Id<T>>
    {
        private readonly string _id;


        /// <include file='Id.doc.xml' path='/doc/member[@name="F:Empty"]/*'/>
        public static readonly Id<T> Empty;

        /// <include file='Id.doc.xml' path='/doc/member[@name="P:IsEmpty"]/*'/>
        [DebuggerHidden]
        public bool IsEmpty
        {
            get
            {
                return (_id == null);
            }
        }

        /// <include file='Id.doc.xml' path='/doc/member[@name="P:IdType"]/*'/>
        [DebuggerHidden]
        public string IdType
        {
            get
            {
                return typeof(T).FullName;
            }
        }

        [DebuggerHidden]
        private Id(string id)
        {
            _id = id;
        }

        /// <include file='Id.doc.xml' path='/doc/member[@name="M:ToString()"]/*'/>
        [DebuggerHidden]
        public override string ToString()
        {
            return _id;
        }

        /// <include file='Id.doc.xml' path='/doc/member[@name="M:Equals(Ingenious.Mvc.Id`1)"]/*'/>
        [DebuggerHidden]
        public bool Equals(Id<T> id)
        {
            bool equal = (string.CompareOrdinal(_id, id._id) == 0);

            return equal;
        }

        /// <include file='Id.doc.xml' path='/doc/member[@name="M:Equals(System.Object)"]/*'/>
        [DebuggerHidden]
        public override bool Equals(object obj)
        {
            if (obj is Id<T>)
            {
                return Equals((Id<T>)obj);
            }

            return false;
        }

        /// <include file='Id.doc.xml' path='/doc/member[@name="M:GetHashCode()"]/*'/>
        [DebuggerHidden]
        public override int GetHashCode()
        {
            if (_id == null)
            {
                return 0;
            }
            else
            {
                return _id.GetHashCode();
            }
        }

        /// <include file='Id.doc.xml' path='/doc/member[@name="M:op_Equality(Ingenious.Mvc.Id`1,Ingenious.Mvc.Id`1)"]/*'/>
        [DebuggerHidden]
        public static bool operator ==(Id<T> id1, Id<T> id2)
        {
            return id1.Equals(id2);
        }

        /// <include file='Id.doc.xml' path='/doc/member[@name="M:op_Inequality(Ingenious.Mvc.Id`1,Ingenious.Mvc.Id`1)"]/*'/>
        [DebuggerHidden]
        public static bool operator !=(Id<T> id1, Id<T> id2)
        {
            return !id1.Equals(id2);
        }

        /// <include file='Id.doc.xml' path='/doc/member[@name="M:op_Implicit(System.String)"]/*'/>
        [DebuggerHidden]
        public static implicit operator Id<T>(string stringId)
        {
 
            return new Id<T>(stringId);
        }

        /// <include file='Id.doc.xml' path='/doc/member[@name="M:op_Implicit(System.Enum)"]/*'/>
        [DebuggerHidden]
        public static implicit operator Id<T>(Enum enumId)
        {


            return new Id<T>(enumId.ToString());
        }
    }
}
